package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.dto.RankRequest;
import com.tencent.wxcloudrun.dto.RankResponse;
import com.tencent.wxcloudrun.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/getHomepageRank")
public class HomeController {

    private final StatisticsService statisticsService;

    @Autowired
    public HomeController(StatisticsService statisticsService) {
        this.statisticsService = statisticsService;
    }

    @PostMapping
    public ApiResponse getHomepageRank(@RequestBody RankRequest request) {
        RankResponse response = statisticsService.getRankData(request);
        return ApiResponse.ok("查询成功", response);
    }
} 